Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/url-parse

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/url-parse

TypeScript definitions for url-parse

  • 1.4.11
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
285K
decreased by-0.79%
Maintainers
1
Weekly downloads
 
Created

What is @types/url-parse?

@types/url-parse provides TypeScript type definitions for the url-parse library, which is used to parse, manipulate, and build URLs in JavaScript.

What are @types/url-parse's main functionalities?

Parsing URLs

This feature allows you to parse a URL into its components such as protocol, hostname, port, pathname, query, and hash.

const URLParse = require('url-parse');
const url = new URLParse('https://example.com:8080/pathname/?search=test#hash');
console.log(url.protocol); // 'https:'
console.log(url.hostname); // 'example.com'
console.log(url.port); // '8080'
console.log(url.pathname); // '/pathname/'
console.log(url.query); // '?search=test'
console.log(url.hash); // '#hash'

Modifying URLs

This feature allows you to modify different parts of a URL and then convert it back to a string.

const URLParse = require('url-parse');
let url = new URLParse('https://example.com/pathname/?search=test#hash');
url.set('protocol', 'http');
url.set('hostname', 'example.org');
url.set('port', '3000');
console.log(url.toString()); // 'http://example.org:3000/pathname/?search=test#hash'

Query String Parsing

This feature allows you to parse the query string into an object for easier manipulation.

const URLParse = require('url-parse');
const url = new URLParse('https://example.com/pathname/?search=test&foo=bar', true);
console.log(url.query); // { search: 'test', foo: 'bar' }

Building URLs

This feature allows you to build a URL by setting its different components and then converting it back to a string.

const URLParse = require('url-parse');
const url = new URLParse('https://example.com');
url.set('pathname', '/newpath');
url.set('query', { search: 'newtest', foo: 'newbar' });
console.log(url.toString()); // 'https://example.com/newpath?search=newtest&foo=newbar'

Other packages similar to @types/url-parse

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc